/*
 * main.cpp
 *
 *  Created on: 03-06-2012
 *      Author: Jakub Chomentowski
 */

#include "GraphIOModule.h"
#include "SpanningTreeCalculator.h"
#include <math.h>
#include <iostream>
#include <sstream>
#include <istream>
#include <string>

int main(int argc, char **argv)
{
	if (argc != 3)
	{
		std::cout
				<< "Nie podano wszystkich argumentow. Musisz podac nazwe pliku wejsciowego i wyjsciowego."
				<< std::endl;
		return 0;
	}
	

	std::string inputFile = argv[1];
	std::string outputFile = argv[2];
	
	/*std::string inputFile = "test4.txt";
	std::string outputFile = "result4.txt";
	*/

	GraphIoModule ioModule;
	GraphDescriptor descriptor;
	GraphDescriptor tree;

	ioModule.read(descriptor, inputFile);

	std::cout<<"Sciezka: "<<descriptor.length<<std::endl;
	std::cout<<"root: "<<descriptor.rootNodeId<<std::endl;

	SpanningTreeCalculator spaningTreeCalculator;

	bool test = spaningTreeCalculator.calculateSpanningTree(descriptor, tree);

	if(test)
		ioModule.write(tree, outputFile, SUCCESS);
	else
		ioModule.write(tree, outputFile, ERROR);

	/*char blup;

	std::cin>>blup;
	*/

	return 0;
}



